package com.Controller 
{
	import com.Model.PlayerScore;
	import com.UI.Background;
	import com.UI.Developer;
	import com.UI.PlayerToolbar;
	import com.UI.Table;
	import flash.display.MovieClip;

	/**
	 * ...
	 * @author Imola
	 */
	public class TestLevelController extends MovieClip
	{
			
		private var bg:Background;
		private var table:Table;
		private var playerToolbar:PlayerToolbar;
		private var tableList:Array = [];
		private var nrOfRows:Number = 0;
		private var nrOfColumns:Number = 0;
		private var gameWidth:Number = 0;
		private var gameHeight:Number = 0;
		private var dev:Developer;
		
		public function TestLevelController(levelWidth:int, levelHeight:int) 
		{
			this.gameHeight = levelHeight;
			this.gameWidth = levelWidth;
		}

		public function setNrOfRows(rows:Number):void {
			this.nrOfRows = rows;
		}
		
		public function setNrOfColumns(columns:Number):void {
			this.nrOfColumns = columns;
		}
		
		public function initTestLevelController():void{
			bg = new Background(gameWidth, gameHeight);
			addChild(bg);
			playerToolbar = new PlayerToolbar(gameWidth, 50);
			playerToolbar.x = 0;
			playerToolbar.y = gameHeight - 50;
			bg.addChild(playerToolbar);
			for (var i:uint = 0; i < nrOfRows; i++) {
				tableList[i] = [];
				for (var j:uint = 0; j < nrOfColumns; j++) {
					table = new Table(i * 160 + 50, j * 60 + 50);
					tableList[i].push(table);
				}
			}
			for (var i:uint = 0; i < nrOfRows; i++) {
				for (var j:uint = 0; j < nrOfColumns; j++){
					bg.addChild(tableList[i][j]);
				}
			}
			dev = new Developer();
			bg.addChild(dev);
		}

		private function bringToFront(mcl:MovieClip):void {
			mcl.parent.setChildIndex(mcl,mcl.parent.numChildren - 1);
		}
	}

}